package org.wendu.wdoa.service.impl;


import org.wendu.wdoa.dao.InfoDao;
import org.wendu.wdoa.common.Department;
import org.wendu.wdoa.common.Utils;
import org.wendu.wdoa.common.page.Page;
import org.wendu.wdoa.dto.InfoDto;
import org.wendu.wdoa.model.EmpUser;
import org.wendu.wdoa.service.InfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;


@Service
@Transactional
public class InfoServiceImpl implements InfoService {

    @Resource
    private InfoDao infoDao;



    @Override
    public Page<EmpUser> getRolePage(InfoDto dto) {
        return Utils.getPage(dto,()->infoDao.getEmpList(dto));
    }

    @Override
    public void addNewUser(EmpUser empUser) {
        infoDao.addUser(empUser);
    }

    @Override
    public void deleteOldUser(Integer id) {
        infoDao.deleteUser(id);
    }

    @Override
    public int findUserId(Integer id) {
       int sum = infoDao.findUserById(id);
       return sum;
    }

    @Override
    public void updataUser(Integer id,Integer userId) {
        infoDao.updateUser(id,userId);
    }

    @Override
    public List<Department> getAllDep() {
        List<Department> dep = infoDao.findDep();
        return dep;
    }
}
